package io.gitee.hchaojie.day02;

import org.junit.Test;

public class Demo {
    private int i;  // 实例变量

    private static int j = 0;

    @Test
    public void testKongZhao() {
        int[][] scores = {
                {11, 12, 13, 14},
                {21, 22, 23, 24},
                {31, 32, 33, 34}
        };

        int row = scores.length;
        int col = scores[0].length;
        for(int j=0;j<col;j++){
            for(int i=row-1;i>=0;i--){
                System.out.print(scores[i][j]+" ");
            }
            System.out.println();
        }
    }

    @Test
    public void test3() {
        int[][] scores = {
                {11, 12, 13, 14},
                {21, 22, 23, 24},
                {31, 32, 33, 34}
        };

        for (int j = 3; j >=0; j--) {
            for (int i =0; i <=2; i++) {
                System.out.print(scores[i][j]+" ");
            }
            System.out.println();
        }
        System.out.println("==========");
    }

    @Test
    public void test2() {
        int[][] scores = {
            {11, 12, 13, 14},
            {21, 22, 23, 24},
            {31, 32, 33, 34}
        };

//        int[][] scores3 = {
//                {31, 21, 11},          //
//                {32, 22, 12},
//                {33, 23, 13},
//                {34, 24, 14|}
//        };
        // 14, 24, 34
        // 13, 23, 33

        int[][] scores2 = new int[4][3];

        for (int j = 3; j >= 0; j--) {
            for (int i = 2; i >= 0; i--) {
                scores2[3 - j][2 - i] = scores[j][i];
            }
        }

        print(scores2);
//        for (int i = 0; i < 4; i++) {
//            for (int j = 0; j < 3; j++) {
//                scores2[i][j] = scores[j][];
//            }
//        }
    }
    
    private void print(int[][] array) {
        for (int i = 0; i < array.length; i++) {
            for (int j = 0; j < array[i].length; j++) {
                System.out.print(array[i][j] + " ");
            }
            
            System.out.println();
        }
    }


    @Test
    public void test() {
//        for (int m = 3; m > 0; m--) {
//            for (int n = 0; n < 4; n++) {
//                System.out.print(m + "" + n + ",");
//            }
//
//            System.out.println();
//        }

        for (int i = 2; i >= 0; i--) {
            for (int j = 0; j <= 3; j++) {
                System.out.print(i + "" + j +",");
            }
            
            System.out.println();
        }
    }

    public static void main(String[] args) {
        Demo d = new Demo();
        d.foo();

        bar();

        Demo.bar();
    }

    public void foo() {
        i = 10;

        System.out.println(j);

        j = 20;
    }

    public static void bar() {
        Demo demo = new Demo();
        demo.i = 10;
    }
}
